home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 11 / FM Towns Free Software Collection 11.iso / t_os / tool / dolmorph / src / alert.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-07  |  5.7 KB  |  212 lines

  1. /*===========================================
  2.           DolphMorph(ドルフモーフ)
  3.  
  4.       モーフィング&変形アニメ作成ソフト
  5.  
  6.   モーフィングアルゴリズム: EAST 1994
  7.   インターフェース作成:     松内 良介 1994
  8. ===========================================*/
  9. #if 0
  10.  
  11.     alert.c
  12.         警告メッセージ、確認メッセージの表示
  13.  
  14.     static    void    setTitleAndMessage(int idTitleMsg, char *title,
  15.                                        int *idDispMsg, int msgNum, char *msg)
  16.  
  17.             void    dispAlertMessage(char *title, char *msg)
  18.             void    alert_noMemory(char *title)
  19.             int        dispCheckMessage(char *title, char *msg, char *okmsg)
  20.  
  21.             int        AlertOkDBtnFunc(kobj, messId, argc, pev, trigger)
  22.             int        CheckAlertOkDBtnFunc(kobj, messId, argc, pev, trigger)
  23.             int        CheckAlertCancelDBtnFunc(kobj, messId, argc, pev, trigger)
  24. #endif
  25.  
  26. #include <stdio.h>
  27. #include <stdlib.h>
  28. #include <string.h>
  29. #include <winb.h>
  30. #include <te.h>
  31. #include <fntb.h>
  32. #include <gui.h>
  33.  
  34. #include <ctype.h>
  35.  
  36. #include "morph.h"
  37. #include "desktop.h"
  38. #include "guisub.h"
  39.  
  40. /*--------------------------------------------------------*/
  41. /*                        部品ID                        */
  42. /*--------------------------------------------------------*/
  43.  
  44.     int    idAlertDlg = -1 ;
  45.     int    idAlertIcon = -1 ;
  46.     int    idAlertTitleMsg = -1 ;
  47.     int    idAlertOkDBtn = -1 ;
  48.     int    idAlertMsg[3] = -1 ;
  49.     int    idCheckAlertDlg = -1 ;
  50.     int    idCheckAlertIcon = -1 ;
  51.     int    idCheckAlertTitleMsg = -1 ;
  52.     int    idCheckAlertMsg[3] = -1 ;
  53.     int    idCheckAlertOkDBtn = -1 ;
  54.     int    idCheckAlertOkMsg = -1 ;
  55.     int    idCheckAlertCancelDBtn = -1 ;
  56.     int    idCheckAlertCancelMsg = -1 ;
  57.  
  58. /*--------------------------------------------------------*/
  59. /*               タイトル、表示文字列の設定               */
  60. /*--------------------------------------------------------*/
  61.  
  62.     static char msgbuf[3][64];    // [3] で決め打ちはよくない…
  63.     static char titlebuf[64];
  64.  
  65.     static void setTitleAndMessage(int idTitleMsg, char *title,
  66.                                     int *idDispMsg, int msgNum, char *msg)
  67.     {
  68.         int idx;
  69.       /* タイトル文字列の設定 */
  70.         titlebuf[0] = 0;
  71.         if (title != NULL)
  72.             strncpy(titlebuf, title, 63);
  73.         MMI_SendMessage(idTitleMsg, MM_SETMSG, 1, title);
  74.       /* 表示文字列の設定 */
  75.         int width;
  76.         FRAME fr;
  77.         RM_getFrame(idDispMsg[0], &fr);
  78.         width = (fr.rdwx - fr.lupx + 1) / 6;
  79.         for (idx=0; idx<msgNum; idx++)
  80.         {
  81.             memset(msgbuf[idx], ' ', width);
  82.             msgbuf[idx][width] = '\0';
  83.         }
  84.         if (msg == NULL)
  85.             goto NOMSG;
  86.         int clm;
  87.         idx = 0;
  88.         clm = 0;
  89.         char *sp;
  90.         sp = msg;
  91.         while (*sp != '\0' && idx < msgNum)
  92.         {
  93.             if (*sp == '\n' || clm >= width-1)
  94.             {
  95.                 idx++;
  96.                 clm = 0;
  97.                 if (*sp == '\n')
  98.                     sp++;
  99.             }
  100.             else if (!_iskanji(*sp))
  101.                 msgbuf[idx][clm++] = *sp++;
  102.             else
  103.             {
  104.                 msgbuf[idx][clm++] = *sp++;
  105.                 msgbuf[idx][clm++] = *sp++;
  106.             }
  107.         }
  108.        NOMSG:;
  109.         for (idx=0; idx<msgNum; idx++)
  110.             MMI_SendMessage(idDispMsg[idx], MM_SETMSG, 1, msgbuf[idx]);
  111.     }
  112.  
  113. /*--------------------------------------------------------*/
  114. /*                   警告メッセージ表示                   */
  115. /*--------------------------------------------------------*/
  116.  
  117.     void dispAlertMessage(char *title, char *msg)
  118.     {
  119.         int idx;
  120.         int moscsr;
  121.         MG_PushPtr(MOSICON_ARROW, &moscsr);
  122.         setTitleAndMessage(idAlertTitleMsg, title,
  123.                            idAlertMsg, INTNUM(idAlertMsg), msg);
  124.         RM_moveCenter(idAlertDlg);
  125.         MTL_setFlagObj(idDesktopSelectiveHyper, MS_UNSELECT) ;
  126.         MMI_SendMessage(idAlertDlg, MM_ATTACH, 1, idDesktopAlertHyper);
  127.         MMI_SendMessage(idAlertDlg, MM_SHOW, 0);
  128.         MMI_ExecSystem();
  129.         MMI_SendMessage(idAlertDlg, MM_ERASE, 0);
  130.         MMI_SendMessage(idAlertDlg, MM_DETACH, 0);
  131.         MTL_resetFlagObj(idDesktopSelectiveHyper, ~MS_UNSELECT) ;
  132.         MG_PopPtr(moscsr);
  133.     }
  134.  
  135.     void alert_noMemory(char *title)
  136.     {
  137.         dispAlertMessage(title, "メモリ容量不足です");
  138.     }
  139.  
  140. /*--------------------------------------------------------*/
  141. /*                   確認メッセージ表示                   */
  142. /*--------------------------------------------------------*/
  143.  
  144.     static int nCheck;
  145.  
  146.     int dispCheckMessage(char *title, char *msg, char *okmsg)
  147.     {
  148.         int idx;
  149.         static char OkMsg[20];
  150.         if (okmsg != NULL)
  151.             strncpy(OkMsg, okmsg, 19);
  152.         else
  153.             strcpy(OkMsg, "続行");
  154.         int moscsr;
  155.         MG_PushPtr(MOSICON_ARROW, &moscsr);
  156.         MMI_SendMessage(idCheckAlertOkMsg, MM_SETMSG, 1, OkMsg);
  157.         setTitleAndMessage(idCheckAlertTitleMsg, title,
  158.                            idCheckAlertMsg, INTNUM(idCheckAlertMsg), msg);
  159.         RM_moveCenter(idCheckAlertDlg);
  160.         MTL_setFlagObj(idDesktopSelectiveHyper, MS_UNSELECT) ;
  161.         MMI_SendMessage(idCheckAlertDlg, MM_ATTACH, 1, idDesktopAlertHyper);
  162.         MMI_SendMessage(idCheckAlertDlg, MM_SHOW, 0);
  163.         MMI_ExecSystem();
  164.         MMI_SendMessage(idCheckAlertDlg, MM_ERASE, 0);
  165.         MMI_SendMessage(idCheckAlertDlg, MM_DETACH, 0);
  166.         MTL_resetFlagObj(idDesktopSelectiveHyper, ~MS_UNSELECT) ;
  167.         MG_PopPtr(moscsr);
  168.         return nCheck;
  169.     }
  170.  
  171. /*--------------------------------------------------------*/
  172. /*                   部品の呼び出し関数                   */
  173. /*--------------------------------------------------------*/
  174.  
  175.     /*    initDataZALERT:idAlertOkDBtn:MJ_DBUTTONL40の呼び出し関数    */
  176.     int    AlertOkDBtnFunc(kobj, messId, argc, pev, trigger)
  177.     int        kobj ;
  178.     int        messId ;
  179.     int        argc ;
  180.     EVENT    *pev ;
  181.     int        trigger ;
  182.     {
  183.         MMI_SetHaltFlag(TRUE);
  184.         return NOERR ;
  185.     }
  186.  
  187.     /*    initDataZALERT:idCheckAlertOkDBtn:MJ_DBUTTONL40の呼び出し関数    */
  188.     int    CheckAlertOkDBtnFunc(kobj, messId, argc, pev, trigger)
  189.     int        kobj ;
  190.     int        messId ;
  191.     int        argc ;
  192.     EVENT    *pev ;
  193.     int        trigger ;
  194.     {
  195.         nCheck = 0;
  196.         MMI_SetHaltFlag(TRUE);
  197.         return NOERR ;
  198.     }
  199.  
  200.     /*    initDataZALERT:idCheckAlertCancelDBtn:MJ_DBUTTONL40の呼び出し関数    */
  201.     int    CheckAlertCancelDBtnFunc(kobj, messId, argc, pev, trigger)
  202.     int        kobj ;
  203.     int        messId ;
  204.     int        argc ;
  205.     EVENT    *pev ;
  206.     int        trigger ;
  207.     {
  208.         nCheck = -1;
  209.         MMI_SetHaltFlag(TRUE);
  210.         return NOERR ;
  211.     }
  212.